generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id        String   @id @default(uuid())
  email     String   @unique
  password  String
  createAt  DateTime @default(now()) @map("create_at")
  updatedAt DateTime @updatedAt @map("updated_at")
  roles     Role[]

  tokens Token[]

  @@index([id])
  @@map("users")
}

enum Role {
  Admin
  User
}

model Token {
  token     String   @unique
  exp       DateTime
  userId    String
  userAgent String   @map("user_agent")

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@map("tokens")
}
